import request  from "@/utils/request";

/**
 * 获取中转的商品数据
 * @param params
 * @returns {Promise<unknown>}
 */
export function getMiddleWorkGoodsList(params = {}){
  return request({
    url: '/middleWorkOrder/getMiddleWorkGoodsList',
    params
  })
}


/**
 * 获取模板数据
 * @returns {Promise<unknown>}
 */
export function getImportTemplateData(){
  return request({
    url: '/middleWorkOrder/getImportTemplateData',
  })
}

/**
 * 获取贴单单价和中转费用
 * @returns {Promise | Promise<unknown>}
 */
export function getMiddleFee(){
  return request({
    url: '/middleWorkOrder/getMiddleFee',
  })
}

/**
 * 保存送仓工单
 * @param data
 * @returns {Promise<unknown>}
 */
export function saveMiddleWorkOrder(data){
  return request({
    url: `/middleWorkOrder/saveMiddleWorkOrder`,
    data,
    method: 'post',
    handleError: true,
  })
}

/**
 * 获取送仓工单列表
 * @param params
 * @returns {Promise<unknown>}
 */
export function getMiddleWorkOrderList(params){
  return request({
    url: `/middleWorkOrder/getMiddleWorkOrderList`,
    params,
    method: 'get',
  })
}

/**
 * 删除送仓工单
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function deleteMiddleWorkOrder(id){
  return request({
    url: `/middleWorkOrder/deleteMiddleWorkOrder/${id}`,
    method: 'delete',
    handleError: true,
  })
}

/**
 * 获取工单详情
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function getMiddleInfo(id){
  return request({
    url: `/middleWorkOrder/getMiddleWorkOrderInfo/${id}`,
    handleError: true,
  })
}

/**
 * 修改工单
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function editMiddleWork(data){
  return request({
    url: `/middleWorkOrder/editMiddleWork`,
    method: 'put',
    data,
  })
}

/**
 * 重新入库
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function cancelWork(id){
  return request({
    url: `/middleWorkOrder/cancelWork/${id}`,
    method: 'patch',
  })
}

/**
 * 取消从新入库
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function deleteCancelWork(id){
  return request({
    url: `/middleWorkOrder/deleteCancelWork/${id}`,
    method: 'patch'
  })
}

/**
 * 获取店铺列表
 * @returns {Promise | Promise<unknown>}
 */
export function getMiddleAllAccountList(){
  return request({
    url: `/middleWorkOrder/getMiddleAllAccountList`,
    method: 'get',
  })
}

/**
 * 计算费用
 * @returns {Promise | Promise<unknown>}
 */
export function calMiddleFee(data){
  return request({
    url: '/middleWorkOrder/calMiddleFee',
    method: 'post',
    data,
  })
}
